// pages/movie/index.js
import QQMapWX from "../../utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk";
var qqmapsdk = new QQMapWX({
  key: 'KXGBZ-U7H36-ZD5S5-EOYGV-J7MXO-ZNBKS' // 必填
});
Page({
  statusBarHeight:wx.getMenuButtonBoundingClientRect().top + wx.getMenuButtonBoundingClientRect().height + "px",

  /**
   * 页面的初始数据
   */
  data: {
    list:[],
    list1:[],
    hot:'',
    will:'',
    change:'change',
    change1:'',
    a:true,
  },
  hot(e){
    console.log(e)
    this.setData({
      change:'change',
      change1:'',
      a:true,
    })
  },
  will(){
    this.setData({
      change1:'change',
      change:'',
      a:false,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  init(){
    var that = this;
    wx.request({
      url: 'http://bufantec.com/api/douban/movie/in_theaters',
      success(res){
        console.log(res)
        that.setData({
          list:res.data.data.list
        })
      }
    }),
    wx.request({
      url: 'http://bufantec.com/api/douban/movie/selectPreview',
      success(res1){
        console.log(res1)
        that.setData({
          list1:res1.data.data
        })
      }
    })
  },
  onLoad: function (options) {
    this.init();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that=this;
    wx.getLocation({
      success(res){
        console.log(res),
        qqmapsdk.reverseGeocoder({
          location: `${res.latitude},${res.longitude}`,
          success(result){
            console.log(result)
            that.setData({
               city:result.result.address_component.city
            })
          }
        });
      }
    })

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})